//
//  HD_HSP_FirstDataViewController.m
//  HDLiaoNingMeseum
//
//  Created by HDHaoShaoPeng on 2017/8/4.
//  Copyright © 2017年 HDNiuKuiming. All rights reserved.
//

#import "HD_HSP_FirstDataViewController.h"
#import "HD_HSP_FirstData_TableViewCell.h"
#import "HD_HSP_ExhibitListViewController.h"

@interface HD_HSP_FirstDataViewController ()
@property (weak, nonatomic) IBOutlet UITableView *myTableview;
@property (weak, nonatomic) IBOutlet UILabel *myTitleLabel;

@end

static NSString *cellName = @"HD_HSP_FirstData_TableViewCell";
static HDDeclare *declare;
@implementation HD_HSP_FirstDataViewController
{
    NSArray *_dataArr;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    declare = [HDDeclare sharedDeclare];
    self.myTitleLabel.text = declare.autoGuide;
    self.myTitleLabel.font = [UIFont fontWithName:@"FZQKBYSJW--GB1-0" size:18.0];
    
    _dataArr = [declare giveMeUnitData];
    [self.myTableview registerNib:[UINib nibWithNibName:cellName bundle:nil] forCellReuseIdentifier:cellName];
    [self.myTableview reloadData];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
    if ([segue.identifier isEqualToString:@"shouListLine"]) {
        HD_HSP_ExhibitListViewController *vc = segue.destinationViewController;
        vc.model = sender;
    }
}


#pragma mark - tableView delegate
#pragma mark - tableView delegate

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return _dataArr.count;
}

-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    HD_HSP_FirstData_TableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellName forIndexPath:indexPath];
    cell.myIndex = indexPath.row;
    cell.model = _dataArr[indexPath.row];
    [cell updateUI];
    return cell;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    [self performSegueWithIdentifier:@"shouListLine" sender:_dataArr[indexPath.row]];
    
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 120.0;
}

//-(UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath
//{   //if (!indexPath.section) return UITableViewCellEditingStyleNone; // 第一组家和公司不提供左滑删除功能
//    return UITableViewCellEditingStyleDelete;
//}
//- (void)tableView:(UITableView*)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath*)indexPath {
//    if (editingStyle == UITableViewCellEditingStyleDelete) {
//        
//        //[self.da removeObjectAtIndex:indexPath.row];
//        [self.myTableView deleteRowsAtIndexPaths:@[indexPath]
//                                withRowAnimation:UITableViewRowAnimationAutomatic];
//        [self.myTableView reloadData];
//    }
//}

//-(BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
//{
//    return YES;
//}

#pragma mark - 点击方法

- (IBAction)backClicked:(id)sender {
    [self.navigationController popViewControllerAnimated:YES];
}



@end
